# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

""" Workspace for Open Source ZetaSQL library """

module(
    name = "zetasql",
    version = "2025.11.2",
)

ZETASQL_JAVA_ARTIFACTS = [
    "com.google.api.grpc:proto-google-common-protos:2.29.0",
    "com.google.code.findbugs:jsr305:3.0.2",
    "com.google.errorprone:error_prone_annotations:2.23.0",
    "com.google.guava:guava:32.1.3-jre",
    "com.google.guava:guava-testlib:32.1.3-jre",
    "io.grpc:grpc-context:1.64.2",
    "io.grpc:grpc-core:1.64.2",
    "io.grpc:grpc-api:1.64.2",
    "io.grpc:grpc-netty:1.64.2",
    "io.grpc:grpc-protobuf-lite:1.64.2",
    "io.grpc:grpc-protobuf:1.64.2",
    "io.grpc:grpc-stub:1.64.2",
    "io.netty:netty-common:4.1.100.Final",
    "io.netty:netty-transport:4.1.100.Final",
    "io.opencensus:opencensus-api:0.31.0",
    "io.opencensus:opencensus-contrib-grpc-metrics:0.31.0",
    "javax.annotation:javax.annotation-api:1.2",
    "joda-time:joda-time:2.10.13",
    "com.google.auto.service:auto-service:1.0-rc2",
    "com.google.code.gson:gson:jar:2.10.1",
    "com.google.protobuf:protobuf-java:3.23.1",
    "com.google.truth:truth:1.1.5",
    "com.google.truth.extensions:truth-proto-extension:1.4.4",
    "junit:junit:4.13.2",
]

bazel_dep(name = "abseil-cpp", version = "20240722.1", repo_name = "com_google_absl")
bazel_dep(name = "abseil-py", version = "2.1.0", repo_name = "io_abseil_py")
bazel_dep(name = "bazel_features", version = "1.30.0")
bazel_dep(name = "bazel_skylib", version = "1.8.1")
bazel_dep(name = "boost.variant", version = "1.89.0")
bazel_dep(name = "boringssl", version = "0.20250818.0")
bazel_dep(name = "civetweb", version = "1.16.bcr.3")
bazel_dep(name = "gazelle", version = "0.45.0", repo_name = "bazel_gazelle")
bazel_dep(name = "google_bazel_common", version = "0.0.1")
bazel_dep(name = "google_benchmark", version = "1.9.4", repo_name = "com_github_google_benchmark")
bazel_dep(name = "googleapis", version = "0.0.0-20250826-a92cee39", repo_name = "com_google_googleapis")
bazel_dep(name = "googleapis-cc", version = "1.0.0")
bazel_dep(name = "googletest", version = "1.17.0", repo_name = "com_google_googletest")
bazel_dep(name = "grpc", version = "1.69.0", repo_name = "com_github_grpc_grpc")
bazel_dep(name = "grpc-java", version = "1.75.0", repo_name = "io_grpc_grpc_java")
bazel_dep(name = "icu", version = "76.1.bcr.3")
bazel_dep(name = "nlohmann_json", version = "3.12.0", repo_name = "json")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "protobuf", version = "29.0", repo_name = "com_google_protobuf")
bazel_dep(name = "re2", version = "2025-08-12", repo_name = "com_googlesource_code_re2")
bazel_dep(name = "riegeli", version = "0.0.0-20240927-cdfb25a", repo_name = "com_google_riegeli")
bazel_dep(name = "rules_bison", version = "0.4")
bazel_dep(name = "rules_cc", version = "0.2.8")
bazel_dep(name = "rules_flex", version = "0.4")
bazel_dep(name = "rules_foreign_cc", version = "0.15.0")
bazel_dep(name = "rules_go", version = "0.53.0", repo_name = "io_bazel_rules_go")
bazel_dep(name = "rules_java", version = "8.15.2")
bazel_dep(name = "rules_jvm_external", version = "6.8")
bazel_dep(name = "rules_m4", version = "0.3")
bazel_dep(name = "rules_pkg", version = "1.1.0")
bazel_dep(name = "rules_proto", version = "7.0.2")
bazel_dep(name = "rules_python", version = "1.6.1")
bazel_dep(name = "toolchains_llvm", version = "1.5.0")

# The 'slot_type' in /zetasql/public/types/internal_utils.h file is a private member of
# absl::container_internal::raw_hash_set in newer versions. Pinged to an older version of abseil-cpp
# until the usage of 'slot_type' is removed.
#
# TODO: Remove the usage of old version of abseil-cpp.
single_version_override(
    module_name = "abseil-cpp",
    version = "20240722.1",
)

# Java dependencies.
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
    artifacts = ZETASQL_JAVA_ARTIFACTS,
    generate_compat_repositories = True,
    repositories = [
        "https://repo1.maven.org/maven2",
    ],
)
use_repo(maven, "maven")

# Go dependencies.
go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(go_deps, "com_github_inspirer_textmapper")

# Python dependencies.
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
    hub_name = "pypi",
    python_version = "3.11",
    requirements_lock = "//:requirements.txt",
)
use_repo(pip, "pypi")

# Dependencies from http_archive
http_archive_deps = use_extension("@zetasql//bazel:http_archive_deps.bzl", "zetasql_http_archive_deps")
use_repo(http_archive_deps, "com_google_cc_differential_privacy", "com_google_differential_privacy", "com_google_farmhash", "com_google_file_based_test_driver", "mstch", "native_utils", "org_publicsuffix")

# Dev toolchain.
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm", dev_dependency = True)
llvm.toolchain(
    name = "llvm_toolchain",
    llvm_versions = {
        "": "21.1.0",
        "darwin-x86_64": "19.1.7",
        "darwin-aarch64": "19.1.7",
    },
)
use_repo(llvm, "llvm_toolchain")

register_toolchains(
    "@llvm_toolchain//:all",
    dev_dependency = True,
)
